home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / os / sprite / RCS / utils.c,v < prev    next >
Encoding:
Text File  |  1992-01-24  |  17.5 KB  |  768 lines

  1. head     1.4;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.4
  10. date     92.01.23.18.22.49;  author stolcke;  state Exp;
  11. branches ;
  12. next     1.3;
  13.  
  14. 1.3
  15. date     91.10.19.13.29.26;  author mendel;  state Exp;
  16. branches ;
  17. next     1.2;
  18.  
  19. 1.2
  20. date     90.03.10.23.25.45;  author tve;  state Exp;
  21. branches ;
  22. next     1.1;
  23.  
  24. 1.1
  25. date     90.02.14.19.25.25;  author tve;  state Exp;
  26. branches ;
  27. next     ;
  28.  
  29.  
  30. desc
  31. @Original X11R4 distribution
  32. @
  33.  
  34.  
  35. 1.4
  36. log
  37. @put -auth back in
  38. @
  39. text
  40. @/***********************************************************
  41. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  42. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  43.  
  44.                         All Rights Reserved
  45.  
  46. Permission to use, copy, modify, and distribute this software and its 
  47. documentation for any purpose and without fee is hereby granted, 
  48. provided that the above copyright notice appear in all copies and that
  49. both that copyright notice and this permission notice appear in 
  50. supporting documentation, and that the names of Digital or MIT not be
  51. used in advertising or publicity pertaining to distribution of the
  52. software without specific, written prior permission.  
  53.  
  54. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  55. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  56. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  57. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  58. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  59. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  60. SOFTWARE.
  61.  
  62. ******************************************************************/
  63. /* $XConsortium: utils.c,v 1.89 89/12/13 09:10:53 rws Exp $ */
  64. #include <stdio.h>
  65. #include "Xos.h"
  66. #include "misc.h"
  67. #include "X.h"
  68. #include "input.h"
  69. #include "opaque.h"
  70. #include <sys/signal.h>
  71. extern char *display;
  72.  
  73. extern long defaultScreenSaverTime;    /* for parsing command line */
  74. extern long defaultScreenSaverInterval;
  75. extern int defaultScreenSaverBlanking;
  76. extern int defaultBackingStore;
  77. extern Bool disableBackingStore;
  78. extern Bool disableSaveUnders;
  79. #ifndef NOLOGOHACK
  80. extern int logoScreenSaver;
  81. #endif
  82. #ifndef SYSV
  83. extern int limitDataSpace, limitStackSpace;
  84. #endif
  85. extern int defaultColorVisualClass;
  86. extern long ScreenSaverTime;        /* for forcing reset */
  87. extern Bool permitOldBugs;
  88. extern int monitorResolution;
  89.  
  90. void ddxUseMsg();
  91.  
  92. extern char *sbrk();
  93.  
  94. #ifdef DEBUG
  95. #ifndef SPECIAL_MALLOC
  96. #define MEMBUG
  97. #endif
  98. #endif
  99.  
  100. #ifdef MEMBUG
  101. #define MEM_FAIL_SCALE 100000
  102. long Memory_fail = 0;
  103. static pointer minfree = NULL;
  104. static void CheckNode();
  105. #endif
  106.  
  107. Bool Must_have_memory = FALSE;
  108.  
  109. char *dev_tty_from_init = NULL;        /* since we need to parse it anyway */
  110.  
  111. /* Force connections to close on SIGHUP from init */
  112.  
  113. AutoResetServer ()
  114. {
  115.     dispatchException |= DE_RESET;
  116.     isItTimeToYield = TRUE;
  117. #ifdef GPROF
  118.     chdir ("/tmp");
  119.     exit (0);
  120. #endif
  121. #ifdef SYSV
  122.     signal (SIGHUP, AutoResetServer);
  123. #endif
  124. }
  125.  
  126. /* Force connections to close and then exit on SIGTERM, SIGINT */
  127.  
  128. GiveUp()
  129. {
  130.     dispatchException |= DE_TERMINATE;
  131.     isItTimeToYield = TRUE;
  132. }
  133.  
  134.  
  135. static void
  136. AbortServer()
  137. {
  138.     extern void AbortDDX();
  139.  
  140.     AbortDDX();
  141.     fflush(stderr);
  142.     abort();
  143. }
  144.  
  145. void
  146. Error(str)
  147.     char *str;
  148. {
  149.     perror(str);
  150. }
  151.  
  152. #if defined (UTEK) || defined (UTEKV)
  153. /*
  154.  * Tektronix has a shared-memory time value which doesn't
  155.  * match gettimeofday at all, but it is only accessible
  156.  * inside the driver.
  157.  */
  158. #else
  159. long
  160. GetTimeInMillis()
  161. {
  162.     struct timeval  tp;
  163.  
  164.     gettimeofday(&tp, 0);
  165.     return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
  166. }
  167. #endif
  168.  
  169. void UseMsg()
  170. {
  171. #if !defined(AIXrt) && !defined(AIX386)
  172.     ErrorF("use: X [:<display>] [option]\n");
  173.     ErrorF("-a #                   mouse acceleration (pixels)\n");
  174. #ifdef MEMBUG
  175.     ErrorF("-alloc int             chance alloc should fail\n");
  176. #endif
  177.     ErrorF("-auth string           select authorization file\n");    
  178.     ErrorF("bc                     enable bug compatibility\n");
  179.     ErrorF("-bs                    disable any backing store support\n");
  180.     ErrorF("-c                     turns off key-click\n");
  181.     ErrorF("c #                    key-click volume (0-100)\n");
  182.     ErrorF("-cc int                default color visual class\n");
  183.     ErrorF("-co string             color database file\n");
  184.     ErrorF("-dpi int               screen resolution in dots per inch\n");
  185.     ErrorF("-f #                   bell base (0-100)\n");
  186.     ErrorF("-fc string             cursor font\n");
  187.     ErrorF("-fn string             default font name\n");
  188.     ErrorF("-fp string             default font path\n");
  189.     ErrorF("-help                  prints message with these options\n");
  190.     ErrorF("-I                     ignore all remaining arguments\n");
  191. #ifndef SYSV
  192.     ErrorF("-ld int                limit data space to N Kb\n");
  193.     ErrorF("-ls int                limit stack space to N Kb\n");
  194. #endif
  195. #ifndef NOLOGOHACK
  196.     ErrorF("-logo                  enable logo in screen saver\n");
  197.     ErrorF("nologo                 disable logo in screen saver\n");
  198. #endif
  199.     ErrorF("-p #                   screen-saver pattern duration (seconds)\n");
  200.     ErrorF("-r                     turns off auto-repeat\n");
  201.     ErrorF("r                      turns on auto-repeat \n");
  202.     ErrorF("-s #                   screen-saver timeout (seconds)\n");
  203.     ErrorF("-su                    disable any save under support\n");
  204.     ErrorF("-t #                   mouse threshold (pixels)\n");
  205.     ErrorF("-to #                  connection time out\n");
  206.     ErrorF("ttyxx                  server started from init on /dev/ttyxx\n");
  207.     ErrorF("v                      video blanking for screen-saver\n");
  208.     ErrorF("-v                     screen-saver without video blanking\n");
  209.     ErrorF("-wm                    WhenMapped default backing-store\n");
  210.     ErrorF("-x string              loads named extension at init time \n");
  211. #ifdef XDMCP
  212.     XdmcpUseMsg();
  213. #endif
  214. #endif /* !AIXrt && ! AIX386 */
  215.     ddxUseMsg();
  216. }
  217.  
  218. /*
  219.  * This function parses the command line. Handles device-independent fields
  220.  * and allows ddx to handle additional fields.  It is not allowed to modify
  221.  * argc or any of the strings pointed to by argv.
  222.  */
  223. void
  224. ProcessCommandLine ( argc, argv )
  225. int    argc;
  226. char    *argv[];
  227.  
  228. {
  229.     int i, skip;
  230.  
  231. #ifdef MEMBUG
  232.     if (!minfree)
  233.     minfree = (pointer)sbrk(0);
  234. #endif
  235.     defaultKeyboardControl.autoRepeat = TRUE;
  236.     permitOldBugs = TRUE;
  237.     for ( i = 1; i < argc; i++ )
  238.     {
  239.     /* call ddx first, so it can peek/override if it wants */
  240.         if(skip = ddxProcessArgument(argc, argv, i))
  241.     {
  242.         i += (skip - 1);
  243.     }
  244.     else if(argv[i][0] ==  ':')  
  245.     {
  246.         /* initialize display */
  247.         display = argv[i];
  248.         display++;
  249.     }
  250.     else if ( strcmp( argv[i], "-a") == 0)
  251.     {
  252.         if(++i < argc)
  253.             defaultPointerControl.num = atoi(argv[i]);
  254.         else
  255.         UseMsg();
  256.     }
  257. #ifdef MEMBUG
  258.     else if ( strcmp( argv[i], "-alloc") == 0)
  259.     {
  260.         if(++i < argc)
  261.             Memory_fail = atoi(argv[i]);
  262.         else
  263.         UseMsg();
  264.     }
  265. #endif
  266.     else if ( strcmp( argv[i], "-auth") == 0)
  267.     {
  268.         if(++i < argc)
  269.             InitAuthorization (argv[i]);
  270.         else
  271.         UseMsg();
  272.     }
  273.     else if ( strcmp( argv[i], "bc") == 0)
  274.         permitOldBugs = TRUE;
  275.     else if ( strcmp( argv[i], "-bs") == 0)
  276.         disableBackingStore = TRUE;
  277.     else if ( strcmp( argv[i], "c") == 0)
  278.     {
  279.         if(++i < argc)
  280.             defaultKeyboardControl.click = atoi(argv[i]);
  281.         else
  282.         UseMsg();
  283.     }
  284.     else if ( strcmp( argv[i], "-c") == 0)
  285.     {
  286.         defaultKeyboardControl.click = 0;
  287.     }
  288.     else if ( strcmp( argv[i], "-cc") == 0)
  289.     {
  290.         if(++i < argc)
  291.             defaultColorVisualClass = atoi(argv[i]);
  292.         else
  293.         UseMsg();
  294.     }
  295.     else if ( strcmp( argv[i], "-co") == 0)
  296.     {
  297.         if(++i < argc)
  298.             rgbPath = argv[i];
  299.         else
  300.         UseMsg();
  301.     }
  302.     else if ( strcmp( argv[i], "-dpi") == 0)
  303.     {
  304.         if(++i < argc)
  305.             monitorResolution = atoi(argv[i]);
  306.         else
  307.         UseMsg();
  308.     }
  309.     else if ( strcmp( argv[i], "-f") == 0)
  310.     {
  311.         if(++i < argc)
  312.             defaultKeyboardControl.bell = atoi(argv[i]);
  313.         else
  314.         UseMsg();
  315.     }
  316.     else if ( strcmp( argv[i], "-fc") == 0)
  317.     {
  318.         if(++i < argc)
  319.             defaultCursorFont = argv[i];
  320.         else
  321.         UseMsg();
  322.     }
  323.     else if ( strcmp( argv[i], "-fn") == 0)
  324.     {
  325.         if(++i < argc)
  326.             defaultTextFont = argv[i];
  327.         else
  328.         UseMsg();
  329.     }
  330.     else if ( strcmp( argv[i], "-fp") == 0)
  331.     {
  332.         if(++i < argc)
  333.             defaultFontPath = argv[i];
  334.         else
  335.         UseMsg();
  336.     }
  337.     else if ( strcmp( argv[i], "-help") == 0)
  338.     {
  339.         UseMsg();
  340.         exit(0);
  341.     }
  342. #ifndef SYSV
  343.     else if ( strcmp( argv[i], "-ld") == 0)
  344.     {
  345.         if(++i < argc)
  346.         {
  347.             limitDataSpace = atoi(argv[i]);
  348.         if (limitDataSpace > 0)
  349.             limitDataSpace *= 1024;
  350.         }
  351.         else
  352.         UseMsg();
  353.     }
  354.     else if ( strcmp( argv[i], "-ls") == 0)
  355.     {
  356.         if(++i < argc)
  357.         {
  358.             limitStackSpace = atoi(argv[i]);
  359.         if (limitStackSpace > 0)
  360.             limitStackSpace *= 1024;
  361.         }
  362.         else
  363.         UseMsg();
  364.     }
  365. #endif
  366. #ifndef NOLOGOHACK
  367.     else if ( strcmp( argv[i], "-logo") == 0)
  368.     {
  369.         logoScreenSaver = 1;
  370.     }
  371.     else if ( strcmp( argv[i], "nologo") == 0)
  372.     {
  373.         logoScreenSaver = 0;
  374.     }
  375. #endif
  376.     else if ( strcmp( argv[i], "-p") == 0)
  377.     {
  378.         if(++i < argc)
  379.             defaultScreenSaverInterval = ((long)atoi(argv[i])) *
  380.                          MILLI_PER_MIN;
  381.         else
  382.         UseMsg();
  383.     }
  384.     else if ( strcmp( argv[i], "r") == 0)
  385.         defaultKeyboardControl.autoRepeat = TRUE;
  386.     else if ( strcmp( argv[i], "-r") == 0)
  387.         defaultKeyboardControl.autoRepeat = FALSE;
  388.     else if ( strcmp( argv[i], "-s") == 0)
  389.     {
  390.         if(++i < argc)
  391.             defaultScreenSaverTime = ((long)atoi(argv[i])) * MILLI_PER_MIN;
  392.         else
  393.         UseMsg();
  394.     }
  395.     else if ( strcmp( argv[i], "-su") == 0)
  396.         disableSaveUnders = TRUE;
  397.     else if ( strcmp( argv[i], "-t") == 0)
  398.     {
  399.         if(++i < argc)
  400.             defaultPointerControl.threshold = atoi(argv[i]);
  401.         else
  402.         UseMsg();
  403.     }
  404.     else if ( strcmp( argv[i], "-to") == 0)
  405.     {
  406.         if(++i < argc)
  407.         TimeOutValue = ((long)atoi(argv[i])) * MILLI_PER_SECOND;
  408.         else
  409.         UseMsg();
  410.     }
  411.     else if ( strcmp( argv[i], "v") == 0)
  412.         defaultScreenSaverBlanking = PreferBlanking;
  413.     else if ( strcmp( argv[i], "-v") == 0)
  414.         defaultScreenSaverBlanking = DontPreferBlanking;
  415.     else if ( strcmp( argv[i], "-wm") == 0)
  416.         defaultBackingStore = WhenMapped;
  417.     else if ( strcmp( argv[i], "-x") == 0)
  418.     {
  419.         if(++i >= argc)
  420.         UseMsg();
  421.         /* For U**x, which doesn't support dynamic loading, there's nothing
  422.          * to do when we see a -x.  Either the extension is linked in or
  423.          * it isn't */
  424.     }
  425.     else if ( strcmp( argv[i], "-I") == 0)
  426.     {
  427.         /* ignore all remaining arguments */
  428.         break;
  429.     }
  430.     else if (strncmp (argv[i], "tty", 3) == 0)
  431.     {
  432.         /* just in case any body is interested */
  433.         dev_tty_from_init = argv[i];
  434.     }
  435. #ifdef XDMCP
  436.     else if ((skip = XdmcpOptions(argc, argv, i)) != i)
  437.     {
  438.         i = skip - 1;
  439.     }
  440. #endif
  441.      else
  442.      {
  443.         UseMsg();
  444.         exit (1);
  445.         }
  446.     }
  447. }
  448.  
  449. #ifndef SPECIAL_MALLOC
  450.  
  451. #ifdef MEMBUG
  452. #define FIRSTMAGIC 0x11aaaa11
  453. #define SECONDMAGIC 0x22aaaa22
  454. #define FREEDMAGIC  0x33aaaa33
  455.  
  456. typedef struct _MallocHeader    *MallocHeaderPtr;
  457.  
  458. typedef struct _MallocHeader {
  459.     unsigned long    amount;
  460.     unsigned long    time;
  461.     MallocHeaderPtr    prev;
  462.     MallocHeaderPtr    next;
  463.     unsigned long    magic;
  464. } MallocHeaderRec;
  465.  
  466. typedef struct _MallocTrailer {
  467.     unsigned long    magic;
  468. } MallocTrailerRec, *MallocTrailerPtr;
  469.  
  470. unsigned long    MemoryAllocTime;
  471. unsigned long    MemoryAllocBreakpoint = ~0;
  472. unsigned long    MemoryActive = 0;
  473. unsigned long    MemoryValidate;
  474.  
  475. MallocHeaderPtr    MemoryInUse;
  476.  
  477. #define request(amount)    ((amount) + sizeof (MallocHeaderRec) + sizeof (MallocTrailerRec))
  478. #define Header(ptr)    ((MallocHeaderPtr) (((char *) ptr) - sizeof (MallocHeaderRec)))
  479. #define Trailer(ptr)    ((MallocTrailerPtr) (((char *) ptr) + Header(ptr)->amount))
  480.  
  481. static unsigned long *
  482. SetupBlock(ptr, amount)
  483.     unsigned long   *ptr;
  484. {
  485.     MallocHeaderPtr    head = (MallocHeaderPtr) ptr;
  486.     MallocTrailerPtr    tail = (MallocTrailerPtr) (((char *) ptr) + amount + sizeof (MallocHeaderRec));
  487.  
  488.     MemoryActive += amount;
  489.     head->magic = FIRSTMAGIC;
  490.     head->amount = amount;
  491.     if (MemoryAllocTime == MemoryAllocBreakpoint)
  492.     head->amount = amount;
  493.     head->time = MemoryAllocTime++;
  494.     head->next = MemoryInUse;
  495.     head->prev = 0;
  496.     if (MemoryInUse)
  497.     MemoryInUse->prev = head;
  498.     MemoryInUse = head;
  499.  
  500.     tail->magic = SECONDMAGIC;
  501.     
  502.     return (unsigned long *)(((char *) ptr) + sizeof (MallocHeaderRec));
  503. }
  504.  
  505. ValidateAllActiveMemory ()
  506. {
  507.     MallocHeaderPtr    head;
  508.     MallocTrailerPtr    tail;
  509.  
  510.     for (head = MemoryInUse; head; head = head->next)
  511.     {
  512.     tail = (MallocTrailerPtr) (((char *) (head + 1)) + head->amount);
  513.         if (head->magic == FREEDMAGIC)
  514.         FatalError("Free data on active list");
  515.         if(head->magic != FIRSTMAGIC || tail->magic != SECONDMAGIC)
  516.         FatalError("Garbage object on active list");
  517.     }
  518. }
  519.  
  520. #endif
  521.  
  522. /* XALLOC -- X's internal memory allocator.  Why does it return unsigned
  523.  * int * instead of the more common char *?  Well, if you read K&R you'll
  524.  * see they say that alloc must return a pointer "suitable for conversion"
  525.  * to whatever type you really want.  In a full-blown generic allocator
  526.  * there's no way to solve the alignment problems without potentially
  527.  * wasting lots of space.  But we have a more limited problem. We know
  528.  * we're only ever returning pointers to structures which will have to
  529.  * be long word aligned.  So we are making a stronger guarantee.  It might
  530.  * have made sense to make Xalloc return char * to conform with people's
  531.  * expectations of malloc, but this makes lint happier.
  532.  */
  533.  
  534. unsigned long * 
  535. Xalloc (amount)
  536.     unsigned long amount;
  537. {
  538.     char        *malloc();
  539.     register pointer  ptr;
  540.     
  541.     if(!amount)
  542.     return (unsigned long *)NULL;
  543.     /* aligned extra on long word boundary */
  544.     amount = (amount + 3) & ~3;
  545. #ifdef MEMBUG
  546.     if (MemoryValidate)
  547.     ValidateAllActiveMemory ();
  548.     if (!Must_have_memory && Memory_fail &&
  549.     ((random() % MEM_FAIL_SCALE) < Memory_fail))
  550.     return (unsigned long *)NULL;
  551.     if (ptr = (pointer)malloc(request(amount)))
  552.     return SetupBlock (ptr, amount);
  553. #else
  554.     if (ptr = (pointer)malloc(amount))
  555.     return (unsigned long *)ptr;
  556. #endif
  557.     if (Must_have_memory)
  558.     FatalError("Out of memory");
  559.     return (unsigned long *)NULL;
  560. }
  561.  
  562. /*****************
  563.  * Xcalloc
  564.  *****************/
  565.  
  566. unsigned long *
  567. Xcalloc (amount)
  568.     unsigned long   amount;
  569. {
  570.     unsigned long   *ret;
  571.  
  572.     ret = Xalloc (amount);
  573.     if (ret)
  574.     bzero ((char *) ret, (int) amount);
  575.     return ret;
  576. }
  577.  
  578. /*****************
  579.  * Xrealloc
  580.  *****************/
  581.  
  582. unsigned long *
  583. Xrealloc (ptr, amount)
  584.     register pointer ptr;
  585.     unsigned long amount;
  586. {
  587.     char *malloc();
  588.     char *realloc();
  589.  
  590. #ifdef MEMBUG
  591.     if (MemoryValidate)
  592.     ValidateAllActiveMemory ();
  593.     if (!amount)
  594.     {
  595.     Xfree(ptr);
  596.     return (unsigned long *)NULL;
  597.     }
  598.     if (!Must_have_memory && Memory_fail &&
  599.     ((random() % MEM_FAIL_SCALE) < Memory_fail))
  600.     return (unsigned long *)NULL;
  601.     amount = (amount + 3) & ~3;
  602.     if (ptr)
  603.     {
  604.     CheckNode(ptr);
  605.     ptr = (pointer)realloc((char *) Header (ptr), request(amount));
  606.     }
  607.     else
  608.     ptr = (pointer)malloc(request(amount));
  609.     if (ptr)
  610.     return SetupBlock (ptr, amount);
  611. #else
  612.     if (!amount)
  613.     {
  614.     if (ptr)
  615.         free(ptr);
  616.     return (unsigned long *)NULL;
  617.     }
  618.     amount = (amount + 3) & ~3;
  619.     if (ptr)
  620.         ptr = (pointer)realloc((char *)ptr, amount);
  621.     else
  622.     ptr = (pointer)malloc(amount);
  623.     if (ptr)
  624.         return (unsigned long *)ptr;
  625. #endif
  626.     if (Must_have_memory)
  627.     FatalError("Out of memory");
  628.     return (unsigned long *)NULL;
  629. }
  630.                     
  631. /*****************
  632.  *  Xfree
  633.  *    calls free 
  634.  *****************/    
  635.  
  636. void
  637. Xfree(ptr)
  638.     register pointer ptr;
  639. {
  640. #ifdef MEMBUG
  641.     if (MemoryValidate)
  642.     ValidateAllActiveMemory ();
  643.     if (ptr)
  644.     {
  645.     MallocHeaderPtr    head;
  646.  
  647.     CheckNode(ptr);
  648.     head = Header(ptr);
  649.     head->magic = FREEDMAGIC;
  650.     free ((char *) head);
  651.     }
  652. #else
  653.     if (ptr)
  654.     free((char *)ptr); 
  655. #endif
  656. }
  657.  
  658. #ifdef MEMBUG
  659. static void
  660. CheckNode(ptr)
  661.     pointer ptr;
  662. {
  663.     MallocHeaderPtr    head;
  664.     MallocHeaderPtr    f, prev;
  665.  
  666.     if (ptr < minfree)
  667.     FatalError("Trying to free static storage");
  668.     head = Header(ptr);
  669.     if (((pointer) head) < minfree)
  670.     FatalError("Trying to free static storage");
  671.     if (head->magic == FREEDMAGIC)
  672.     FatalError("Freeing something already freed");
  673.     if(head->magic != FIRSTMAGIC || Trailer(ptr)->magic != SECONDMAGIC)
  674.     FatalError("Freeing a garbage object");
  675.     if(head->prev)
  676.     head->prev->next = head->next;
  677.     else
  678.     MemoryInUse = head->next;
  679.     if (head->next)
  680.     head->next->prev = head->prev;
  681.     MemoryActive -= head->amount;
  682. }
  683.  
  684. DumpMemoryInUse (time)
  685.     unsigned long   time;
  686. {
  687.     MallocHeaderPtr    head;
  688.  
  689.     for (head = MemoryInUse; head; head = head->next)
  690.     if (head->time >= time)
  691.         printf ("0x%08x %5d %6d\n", head,
  692.                     head->amount,
  693.                     head->time);
  694. }
  695.  
  696. static unsigned long    MarkedTime;
  697.  
  698. MarkMemoryTime ()
  699. {
  700.     MarkedTime = MemoryAllocTime;
  701. }
  702.  
  703. DumpMemorySince ()
  704. {
  705.     DumpMemoryInUse (MarkedTime);
  706. }
  707. #endif
  708. #endif /* SPECIAL_MALLOC */
  709.  
  710. /*VARARGS1*/
  711. void
  712. FatalError(f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9) /* limit of ten args */
  713.     char *f;
  714.     char *s0, *s1, *s2, *s3, *s4, *s5, *s6, *s7, *s8, *s9;
  715. {
  716.     ErrorF("\nFatal server bug!\n");
  717.     ErrorF(f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
  718.     ErrorF("\n");
  719.     AbortServer();
  720.     /*NOTREACHED*/
  721. }
  722.  
  723. /*VARARGS1*/
  724. void
  725. ErrorF( f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9) /* limit of ten args */
  726.     char *f;
  727.     char *s0, *s1, *s2, *s3, *s4, *s5, *s6, *s7, *s8, *s9;
  728. {
  729.     fprintf( stderr, f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
  730. }
  731. @
  732.  
  733.  
  734. 1.3
  735. log
  736. @*** empty log message ***
  737. @
  738. text
  739. @d227 7
  740. @
  741.  
  742.  
  743. 1.2
  744. log
  745. @removed authorization hook
  746. @
  747. text
  748. @d197 1
  749. a197 1
  750.  
  751. @
  752.  
  753.  
  754. 1.1
  755. log
  756. @Initial revision
  757. @
  758. text
  759. @a226 7
  760.     else if ( strcmp( argv[i], "-auth") == 0)
  761.     {
  762.         if(++i < argc)
  763.             InitAuthorization (argv[i]);
  764.         else
  765.         UseMsg();
  766.     }
  767. @
  768.